import request from '@/service/index.js'

export const queryCategories = () => {
  return request.get('/category')
}

export const deleteCategoryById = (id) => {
  return request.delete('/category', {
    params: { id },
  })
}

export const queryFirstTwoLevelsOfCategories = () => {
  return request.get('/category/top/and/secondary')
}

export const addCategory = (data) => {
  return request.post('/category', data)
}
export const queryCategoryParentName = (id) => {
  return request.get('/category/parent/name', {
    params: { id },
  })
}

export const modifyCategory = (data) => {
  return request.put('/category', data)
}

export const changeCategoryStatus = (id, status) => {
  return request.patch(`/category/status/${status}`, null, {
    params: {
      id: id,
    },
  })
}

export const queryCompleteCategoryList = () => {
  return request.get('/category/complete')
}

export const queryTopWithoutRankingCategoryList = () => {
  return request.get('/category/top/without/ranking')
}

export const updateCategoryStatus = (id, status) => {
  return request.patch(`/category/update/status`, null, {
    params: {
      categoryId: id,
      status,
    },
  })
}

export const queryTopCategories = () => {
  return request.get('/category/top/category')
}

export const querySecondaryCategoryList = () => {
  return request.get('/category/secondary/category')
}

export const addNewCategory = (data) => {
  return request.post('/category/add/category', data)
}

export const updateCategory = (data) => {
  return request.put('/category/update/category', data)
}

export const deleteCategory = (id) => {
  return request.delete('/category/delete/category', {
    params: {
      id: id,
    },
  })
}
